//
//  CollectionTableViewCell.m
//  Food
//
//  Created by 15 on 15/7/21.
//  Copyright (c) 2015年 李志远. All rights reserved.
//

#import "CollectionTableViewCell.h"
#import "UIImageView+WebCache.h"
#import "AFNet.h"
@implementation CollectionTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.lblBrowse = [[UILabel alloc] init];
        [self.contentView addSubview:self.lblBrowse];
        self.lblCollection = [[UILabel alloc] init];
        [self.contentView addSubview:self.lblCollection];
        self.lblMaterial = [[UILabel alloc] init];
        [self.contentView addSubview:self.lblMaterial];
        self.lblName = [[UILabel alloc] init];
        [self.contentView addSubview:self.lblName];
        self.imgFood = [[UIImageView alloc] init];
        [self.contentView addSubview:self.imgFood];
    }
    return self;
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    self.imgFood.frame = CGRectMake(5, 5, 100, 70);
    self.lblName.frame = CGRectMake(self.imgFood.frame.size.width + 10, 10, 180, 20);
    self.lblBrowse.frame = CGRectMake(self.lblName.frame.origin.x, 50, 120, 20);
    self.lblCollection.frame = CGRectMake(self.lblBrowse.frame.origin.x + self.lblBrowse.frame.size.width , self.lblBrowse.frame.origin.y, 100, 20);

}

- (void)setModel:(DrawerModel *)model
{
    if (_model != model) {
        [_model release];
        _model = [model retain];
    }
    [self.imgFood setImageWithURL:[NSURL URLWithString:self.model.img] placeholderImage:[UIImage imageNamed:@"minzu"]];
    NSLog(@"%@", self.model.img);
    self.lblName.text = self.model.name;
    self.lblCollection.text = [NSString stringWithFormat:@"%@收藏", self.model.favorites];
    self.lblBrowse.text = [NSString stringWithFormat:@"%@浏览", self.model.allClick];
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
